import { createApp } from 'vue'
import App from './App.vue'

import '@/style/reset.scss'
import '@/style/base.scss'

import router from './router'

// 引入懒加载插件
import {lazyPlugin} from '@/directives'


// 引入全局组件
import TridentHeader from '@/components/TridentHeader.vue'
import TridentFooter from '@/components/TridentFooter.vue'
import TridentGoodsItem from '@/components/TridentGoodsItem.vue'
import TridentBackTop from '@/components/TridentBackTop.vue'
import TridentNumbox from '@/components/TridentNumbox.vue'
import TridentCarousel from '@/components/TridentCarousel.vue'
import TridentEmpty from '@/components/TridentEmpty.vue'
import TridentCheckbox from '@/components/TridentCheckbox.vue'
import TridentGuessLike from '@/components/TridentGuessLike.vue'
import TridentGoodsItemSkeleton from '@/components/TridentGoodsItemSkeleton.vue'

// 导入 pinia 实例
import pinia from "./stores"

// 引入全局守卫文件
import './guard'

// 引入ElementPlus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'

const app = createApp(App)

// 注册全局组件
app.component('TridentHeader', TridentHeader)
app.component('TridentFooter', TridentFooter)
app.component('TridentGoodsItem', TridentGoodsItem)
app.component('TridentBackTop', TridentBackTop)
app.component('TridentNumbox', TridentNumbox)
app.component('TridentCarousel', TridentCarousel)
app.component('TridentEmpty', TridentEmpty)
app.component('TridentCheckbox', TridentCheckbox)
app.component('TridentGuessLike', TridentGuessLike)
app.component('TridentGoodsItemSkeleton', TridentGoodsItemSkeleton)

// 配置全局变量 页面中使用 inject 接收
app.provide('global',{
    FILE_DOMAIN: import.meta.env.VITE_MINIO_FILE_DOMAIN,
    FILE_SERVER: import.meta.env.VITE_FILE_SERVER
})


// 使用pinia
app.use(pinia)

// 使用图片懒加载插件
app.use(lazyPlugin)

// 使用路由
app.use(router)

app.use(ElementPlus, {
    locale: zhCn,
})

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}


app.mount('#app')
